import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入子路由
import user from './modules/user'
import shopping from './modules/shopping'
import home from './modules/home'
Vue.use(VueRouter)
// 将路由模块注入数组
const shakyRoutes = [user, shopping, home]

const routes = [
  {
    path: '/',
    name: 'layout',
    component: () => import('@/views/Layout'),
    meta: { title: '首页', icon: 'wap-home-o' },
    redirect: '/home',
    children: [...shakyRoutes]
  },
  {
    path: '/list',
    name: 'list',
    component: () => import('@/views/list'),
    meta: { title: '商品列表' }
  },
  {
    path: '/reg',
    name: 'reg',
    component: () => import('@/views/Reg'),
    meta: { title: '注册' }
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login'),
    meta: { title: '登录' }
  },
  {
    path: '/info',
    name: 'info',
    component: () => import('@/views/info'),
    meta: { title: '详情' }
  },
  {
    path: '/buy',
    name: 'buy',
    component: () => import('@/views/buy'),
    meta: { title: '购买' }
  }
]

const router = new VueRouter({
  routes
})

export default router
